<?php
	/*
		 _____ __ __ _____ _____ _____ _____    _____ _ _     
		|     |  |  |   __|_   _|   __| __  |  |   __|_| |___ 
		|  |  |_   _|__   | | | |   __|    -|  |   __| | | -_|
		|_____| |_| |_____| |_| |_____|__|__|  |__|  |_|_|___|
		                                                      
		                                                              
		 _____ _                          _____         _             
		|   __| |_ ___ ___ ___ ___ ___   |   __|_ _ ___| |_ ___ _____ 
		|__   |  _| . |  _| .'| . | -_|  |__   | | |_ -|  _| -_|     |
		|_____|_| |___|_| |__,|_  |___|  |_____|_  |___|_| |___|_|_|_|
		                      |___|            |___|                  
		                 
		 ___ ___ ___ ___     -
		|_  |   |   |   |___| |_
		|  _| | | | | | |  _|___|
		|___|___|___|___|___|
		
		NitricWare Studios Linz an der Donau
	*/
	if ($_GET["action"] == "logout"){
		include("./System/Kernel/Includes/logout.include.php");
	}
	
	require_once("./System/Kernel/functions.php");
	require_once("./System/Kernel/template.class.php");
	require_once("./System/Kernel/pclzip.lib.php");
	require_once("./System/Security/settings.php");
	date_default_timezone_set(TIMEZONE);
	$log_date = date("d-m-y", time());
	$log_compl = "Logs/".$log_date.".log";
	if(!file_exists($log_compl)){
		oyster_log("MSG", $log_date, "Oyster 2000c Main");
	}
	
	if(file_exists("./System/Languages/".USE_LANG."/")){
		$language = simplexml_load_file("./System/Languages/".USE_LANG."/strings.xml");
		require_once("./System/Languages/".USE_LANG."/arrays.php");
	}
	
	if (SHOW_SYSTEMFILES == false){
		require_once("./System/Security/restrictions.php");
	}
	
	require_once("./System/Security/master_restrictions.php");
	
	$head = new Template();
	$template = new Template();
	$footer = new Template();
	
	$head->_template_assign("DESIGN", DESIGN);
	$head->_template_assign("CAPTION_ROOT", (string)$language->captions->value_1);
	$head->_template_assign("CAPTION_PASSWORD", (string)$language->captions->value_2);
	$head->_template_assign("CAPTION_LOG", (string)$language->captions->value_3);
	$head->_template_assign("CAPTION_UPLOAD", (string)$language->captions->value_4);
	$head->_template_assign("CAPTION_EDITOR", (string)$language->captions->value_5);
	$head->_template_assign("CAPTION_MONALISA", (string)$language->captions->value_6);
	$head->_template_assign("CAPTION_INPUT", (string)$language->legends->value_2);
	$head->_template_assign("CAPTION_GOTO", (string)$language->buttons->value_2);
	$head->_template_assign("CAPTION_QUICKNOTE", (string)$language->buttons->value_4);
	$head->_template_assign("CAPTION_MKDIR", (string)$language->buttons->value_3);
	$head->_template_assign("CAPTION_ERROR", (string)$language->legends->value_1);
	$head->_template_assign("CAPTION_HINT", (string)$language->legends->value_3);
	
	
	$footer->_template_read("./System/Design/Templates/footer.html");
	
	if (USE_PASSWORD == true){
		if (!isset($_COOKIE["oyster2000cl"]) OR $_COOKIE["oyster2000cl"] != file_get_contents("./System/Security/password.txt")){
			include("./System/Kernel/Includes/login.include.php");
			exit();
		}
		$head->_template_assign("LOGOUT", (string)$language->common->value_48);
	}
	
	$head->_template_read("./System/Design/Templates/head.html");
	$footer->_template_read("./System/Design/Templates/footer.html");
	
	if (ALLOW_UPLOAD == true){
		$head->_template_assign("ALLOW_UPLOAD", ALLOW_UPLOAD);
	}
	
	if (ALLOW_EDITOR == true){
		$head->_template_assign("ALLOW_EDITOR", ALLOW_EDITOR);
		$template->_template_assign("ALLOW_EDITOR", ALLOW_EDITOR);
	}
	
	if (ALLOW_MONALISA == true){
		$head->_template_assign("ALLOW_MONALISA", ALLOW_MONALISA);
		$template->_template_assign("ALLOW_MONALISA", ALLOW_MONALISA);
	}
	
	if (isset($_GET["action"])){
		if ($_GET["action"] != "application"){
			if (!file_exists("./System/Kernel/Includes/".$_GET["action"].".php")) {
				include("./System/Kernel/Includes/index.include.php");
				$head->_template_assign("ERROR", (string)$language->errors->value_32);
			} else {
				include("./System/Kernel/Includes/".$_GET["action"].".php");
			}
		} else {
			if (!file_exists("Applications/".$_GET["app"]."/".$_GET["app"].".php")) {
				include("./System/Kernel/Includes/index.include.php");
				$head->_template_assign("ERROR", (string)$language->errors->value_31);
			} else {
				include("Applications/".$_GET["app"]."/".$_GET["app"].".php");
			}
		}
	} else {
		include("./System/Kernel/Includes/index.include.php");
	}
	
	echo $head->_template_toHTML();
	echo $template->_template_toHTML();
	echo $footer->_template_toHTML();
?>